package com.qifn.blog.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qifn.blog.Dao.TagDao;
import com.qifn.blog.Model.Tag;
import com.qifn.blog.Service.TagService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TagServiceImpl implements TagService {

    @Resource
    TagDao tagDao;

    @Override
    public List<Tag> queryAdminReleaseAllTag() {
        return tagDao.queryAdminReleaseAllTag();
    }

    @Override
    public PageInfo<Tag> queryAdminAllTag(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Tag> tagList = tagDao.queryAdminReleaseAllTag();
        PageInfo<Tag> tagPageInfo = new PageInfo<>(tagList);
        return tagPageInfo;
    }

    @Override
    public boolean deleteTagById(Integer tagId) {
        Integer one = tagDao.adminDeleteTagById(tagId);
        if(one > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean insertTag(Tag tag) {
        Integer one = tagDao.adminInsertTag(tag);
        if(one > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Tag> queryAllTag(){
        return tagDao.queryAllTag();
    }
}
